<?php 

require_once './include_util.php';
session_start();

$result = null;
if (array_key_exists("submit", $_REQUEST)) {
	require_once '../lib/Methods.php';
	$method = GG_API_Methods::newMethodAdsNew();
	configApiMethod($method);
	$method->setUseRequestParams(false);
	$method->setParams(getRequestParams());

	require_once '../lib/UploadedImages.php';
	$imageDatas = GG_API_UploadedImages::getEncodedDatas("images");
	$method->setParam("imageDatas", $imageDatas);
	
	$result = $method->call();
}

?>

<?php
	$tpl = array(
		"title" => "ads/new",
		"url" => "adsNew.php",
	);
	include './include_header.php';
?>
<form action="" method="POST" enctype="multipart/form-data">
	<table cellpadding="0" cellspacing="1">
		<?php include './include_formFieldsSettings.php'; ?>
		<tr>
				<td class="Label">cityId:</td>
				<td><input type="text" class="Input" name="cityId" value="47"/></td>
			</tr>
			<tr>
				<td class="Label">categoryId:</td>
				<td><input type="text" class="Input" name="categoryId" value="18"/></td>
			</tr>
			<tr>
				<td class="Label">term:</td>
				<td><input type="text" class="Input" name="term" value="6"/></td>
			</tr>
			<tr>
				<td class="Label">title:</td>
				<td><input type="text" class="Input" name="title"
					value="API sandbox + images"/></td>
			</tr>
			<tr>
				<td class="Label">description:</td>
				<td><textarea class="Input" name="description" rows="5"
					>Desc of mega-cool ad.</textarea></td>
			</tr>
			<tr>
				<td class="Label">phone:</td>
				<td><input type="text" class="Input" name="phone" value="123123"/></td>
			</tr>
		<tr>
			<td class="Label">imageUrls[]:</td>
			<td><input type="text" class="Input" name="imageUrls[]"
				value=""/></td>
		</tr>
		<tr>
			<td class="Label">imageUrls[]:</td>
			<td><input type="text" class="Input" name="imageUrls[]"
				value=""/></td>
		</tr>
		<tr>
			<td class="Label">images[]:</td>
			<td><input type="file" class="Input" name="images[]"/></td>
		</tr>
		<tr>
			<td class="Label">images[]:</td>
			<td><input type="file" class="Input" name="images[]"/></td>
		</tr>
		<tr>
			<td class="Label">&nbsp;</td>
			<td><input type="submit" class="Submit" name="submit" value="Call"/></td>
		</tr>
	</table>
</form>
<?php include './include_footer.php'; ?>
